import Mock from "mockjs";

import { Menu } from "../../types/utils.interface";


Mock.mock("http://localhost:9999/router", "post", (type: { body: string }) => {
  //  if(body.type)
  const data = JSON.parse(type?.body);
  if (data.type == "admin") {
    return {
      code: 20000,
      data: {
        router: [
          {
            id: 9,
            name: "login",
            code: null,
            description: null,
            url: "/login",
            component: "login/login",
            generatemenu: 1,
            sort: 0,
            parentId: null,
            permName: null,
          },
          {
            id: 1,
            name: "index",
            code: null,
            description: null,
            url: "/",
            component: "index",
            generatemenu: 1,
            sort: 0,
            parentId: null,
            permName: null,
            // title: "",
            // icon: "",
            children: [
              {
                id: 2,
                name: "Dashboard",
                code: null,
                description: null,
                url: "/",
                component: "dashboard/dashboard",
                generatemenu: 1,
                sort: 0,
                parentId: 1,
                permName: null,
                redirect: "",
                title: "控制台",
                icon: "DashboardOutlined",
                children: null,
              },
              {
                id: 3,
                name: "Error401",
                code: null,
                description: null,
                url: "/error/401",
                component: "errorpage/401",
                generatemenu: 1,
                sort: 0,
                parentId: 1,
                permName: null,
                redirect: "",
                title: "错误401",
                icon: null,
                children: null,
              },
              {
                id: 4,
                name: "Error403",
                code: null,
                description: null,
                url: "/error/403",
                component: "errorpage/403",
                generatemenu: 1,
                sort: 0,
                parentId: 1,
                permName: null,
                redirect: "",
                title: "错误403",
                icon: null,
                children: null,
              },
              {
                id: 5,
                name: "Error404",
                code: null,
                description: null,
                url: "/error/404",
                component: "errorpage/404",
                generatemenu: 1,
                sort: 0,
                parentId: 1,
                permName: null,
                redirect: "",
                title: "错误404",
                icon: null,
                children: null,
              },
              {
                id: 6,
                name: "projectlist",
                code: null,
                description: null,
                url: "/project/list",
                component: "project/projectlist",
                generatemenu: 1,
                sort: 0,
                parentId: 1,
                permName: null,
                redirect: "",
                title: "项目列表",
                icon: null,
                children: null,
              },
              {
                id: 6,
                name: "jurisdiction",
                code: null,
                description: null,
                url: "/jurisdiction",
                component: "jurisdiction/jurisdiction",
                generatemenu: 1,
                sort: 0,
                parentId: 1,
                permName: null,
                redirect: "",
                title: "权限指令",
                icon: null,
                children: null,
              },
            ],
          },
        ],
        permit: ["add", "delete", "edit", "view"],
      },
    };
  } else if (data.type == "editr") {
    return {
      code: 20000,
      data: {
        router: [
          {
            id: 9,
            name: "login",
            code: null,
            description: null,
            url: "/login",
            component: "login/login",
            generatemenu: 1,
            sort: 0,
            parentId: null,
            permName: null,
          },
          {
            id: 1,
            name: "index",
            code: null,
            description: null,
            url: "/",
            component: "index",
            generatemenu: 1,
            sort: 0,
            parentId: null,
            permName: null,
            // title: "",
            // icon: "",
            children: [
              {
                id: 2,
                name: "Dashboard",
                code: null,
                description: null,
                url: "/",
                component: "dashboard/dashboard",
                generatemenu: 1,
                sort: 0,
                parentId: 1,
                permName: null,
                redirect: "",
                title: "控制台",
                icon: "DashboardOutlined",
                children: null,
              },
              {
                id: 3,
                name: "Error401",
                code: null,
                description: null,
                url: "/error/401",
                component: "errorpage/401",
                generatemenu: 1,
                sort: 0,
                parentId: 1,
                permName: null,
                redirect: "",
                title: "错误401",
                icon: null,
                children: null,
              },
              {
                id: 4,
                name: "Error403",
                code: null,
                description: null,
                url: "/error/403",
                component: "errorpage/403",
                generatemenu: 1,
                sort: 0,
                parentId: 1,
                permName: null,
                redirect: "",
                title: "错误403",
                icon: null,
                children: null,
              },
              {
                id: 5,
                name: "Error404",
                code: null,
                description: null,
                url: "/error/404",
                component: "errorpage/404",
                generatemenu: 1,
                sort: 0,
                parentId: 1,
                permName: null,
                redirect: "",
                title: "错误404",
                icon: null,
                children: null,
              },
            ],
          },
        ],
        permit: ["edit", "view"],
      },
    };
  }
});

Mock.mock("http://localhost:9999/sider", "post", (type: { body: string }) => {
  const data = JSON.parse(type?.body);
  if (data.type == "admin") {
    return {
      code: 20000,
      data: {
        router: <Menu[]>[
          {
            icon: "DashboardOutlined",
            title: "控制台",
            path: "/",
          },
          {
            icon: "WarningOutlined",
            title: "异常页",
            children: [
              {
                title: "401",
                path: "/error/401",
              },
              {
                title: "403",
                path: "/error/403",
              },
              {
                title: "404",
                path: "/error/404",
              },
            ],
          },
          {
            icon: "UngroupOutlined",
            title: "多级导航",
            children: [
              {
                title: "二级导航",
                icon: "UngroupOutlined",
                children: [
                  {
                    title: "三级导航",
                    path: "/asdas",
                  },
                ],
              },
            ],
          },
          {
            title: "项目管理",
            icon: "DatabaseOutlined",
            children: [
              {
                title: "项目列表",
                path: "/project/list",
              },
            ],
          },
          {
            title: "权限管理",
            icon: "VerifiedOutlined",
            children: [
              {
                title: "指令管理",
                path: "/jurisdiction",
              },
            ],
          },
        ],
      },
    };
  } else if (data.type == "editor") {
    return {
      code: 20000,
      data: {
        router: <Menu[]>[
          {
            icon: 'DashboardOutlined',
            title: "控制台",
            path: "/",
          },
          {
            icon: 'WarningOutlined',
            title: "异常页",
            children: [
              {
                title: "401",
                path: "/error/401",
              },
              {
                title: "403",
                path: "/error/403",
              },
              {
                title: "404",
                path: "/error/404",
              },
            ],
          },
          {
            title: "权限管理",
            icon: 'VerifiedOutlined',
            children: [
              {
                title: "指令管理",
                path: "/jurisdiction",
              },
            ],
          },
        ],
      },
    };
  }
});
